using System;

namespace Tool
{
    /// <summary>
    /// 返回的数据
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class ResultData<T>
    {
        public ResultData()
        {
            Timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="succeeded">执行成功,默认false</param>
        /// <param name="errors">错误消息</param>
        public ResultData(bool succeeded = false, object errors = default) : base()
        {
            this.Succeeded = succeeded;
            this.Errors = errors;
            Timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
        }


        /// <summary>
        /// 执行成功
        /// </summary>
        public bool Succeeded { get; set; }

        /// <summary>
        /// 状态码
        /// </summary>
        public int StatusCode { get; set; }

        ///// <summary>
        ///// 出现错误时返回的编码
        ///// </summary>
        //public int? Code { get; set; }

        /// <summary>
        /// 错误代码
        /// </summary>
        public object ErrorCode { get; set; }

        /// <summary>
        /// 错误信息
        /// </summary>
        public object Errors { get; set; }

        /// <summary>
        /// 数据
        /// </summary>
        public T Data { get; set; }

        /// <summary>
        /// 附加数据
        /// </summary>
        public object Extras { get; set; }

        /// <summary>
        /// 时间戳
        /// </summary>
        public long Timestamp { get; set; }
    }
}